package com.xuexiang.xuidemo.slice.button;

import com.xuexiang.xui_lib.component.shadow.ShadowButton;
import com.xuexiang.xuidemo.ResourceTable;
import com.xuexiang.xuidemo.provider.ButtonMainAdapter;
import com.xuexiang.xuidemo.slice.*;

import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ListContainer;

public class ButtonMainAbilitySlice extends BaseAbilitySlice {

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_slice_button);
        findComponentById(ResourceTable.Id_back).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                terminate();
            }
        });
        initView();
    }

    private void initView() {
        ListContainer listContainer = (ListContainer) findComponentById(ResourceTable.Id_list_container);
        listContainer.setItemProvider(new ButtonMainAdapter());
        listContainer.setItemClickedListener((listContainer1, component, position, l) -> jumpPage(position));
    }

    private void jumpPage(int position) {
        switch (position) {
            case 0:
                present(new UnifiedButtonSlice(), new Intent());
                break;
            case 1:
                present(new ShadowButtonSlice(), new Intent());
                break;
            case 2:
                present(new ShadowViewSlice(), new Intent());
                break;
            case 3:
                present(new RoundButtonSlice(), new Intent());
                break;
            case 4:
                present(new CommButtonSlice(), new Intent());
                break;
            case 5:
                present(new SwitchButtonSlice(), new Intent());
                break;
            case 6:
                present(new RippleViewSlice(), new Intent());
                break;
            case 8:
                present(new SmoothCheckBoxSlice(), new Intent());
                break;
            case 9:
                present(new GoodButtonSlice(), new Intent());
                break;
            case 10:
                present(new ShineButtonSlice(), new Intent());
                break;
        }
    }
}
